package controllers;

import play.*;
import play.data.validation.Required;
import play.mvc.*;

import helper.RedirectHelp;

import java.util.*;

import models.*;

public class appstore extends Controller{
    public static void library(int page) {
    	
 	   RedirectHelp.setRedirectPath(response, request.url);
	   User user = GateKeeper.checkLogin();	   
    	List<Appliance> appliances = Appliance.find("order by postedAt desc").from((page-1)*7).fetch(7);
    	long num = Appliance.count();
    	long pages = num/9;
    	long left = num%9;
    	if (left != 0) pages=pages+1;	
    	render(user,page,appliances,pages);
    }
    

/*    public static void show(int page){    
        List<Appliance> appliances = Appliance.find("order by postedAt desc").from(page*5).fetch(5);
        long num = Appliance.count();
        long pages = num/5;
        long left = num%5;
        render(page,appliances,pages,left);
    }
*/
}
